import time, random

setGlobalDuration(20)

a = genDiscreetTable([3,4,5,6,7,8,9,10])

oscReceive(bus='init', address='/init', port=8000)

discreetTableLoop(bus='pit', table=a, speed=.125, reinittrigbus='init')

sine(pitch=100, pitchVar='pit', amplitude=.5)

proc = startCsound()

time.sleep(1)

def newPitches():
    pitches = random.sample([3,4,5,6,7,8,9,10], random.randint(2,8))
    reGenDiscreetTable(a, pitches, proc)

pat = pattern(time=2, function=newPitches)
pat.start()
pat.play()

def t():
    sendOscTrigger(value=1, address='/init')
